﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using IconManager.ObjectModel;

namespace IconManager
{
	/// <summary>
	/// Summary description for IconManagerWebService
	/// </summary>
	[WebService(Namespace = "http://tempuri.org/")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[System.ComponentModel.ToolboxItem(false)]
	// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
	[System.Web.Script.Services.ScriptService]
	public class IconManagerWebService : System.Web.Services.WebService
	{
		/// <summary>
		/// Activates the icon, by copying it to ~/umbraco/images/umbraco/
		/// </summary>
		/// <param name="iconPack">The name of the icon collection folder</param>
		/// <param name="iconFileName">The name of the icon file</param>
		/// <returns>returns true if icon has been successfully activated</returns>
		[WebMethod]
		public bool ActivateIcon(string iconPack, string iconFileName)
		{
			return new PackIcon(iconPack, iconFileName).Activate();
		}

		/// <summary>
		/// Deletes the icon file from ~/umbraco/images/umbraco/ if it's not currently in use
		/// </summary>
		/// <param name="iconFileName">Name of the icon file.</param>
		/// <returns>returns true if icon successfully deactivated</returns>
		[WebMethod]
		public bool DeActivateIcon(string iconFileName)
		{
			return new UmbracoIcon(iconFileName).DeActivate();
		}

		// TODO: method to return details for an icon... 
		// return a serialized object model class to JSON...
	}
}
